Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concept: Pipelines and Command Lists #714

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

glennj
Copy link
Contributor

@glennj glennj commented Nov 25, 2024

No description provided.

@glennj glennj marked this pull request as draft November 25, 2024 23:32
@glennj glennj requested a review from a team November 25, 2024 23:37
concepts/pipelines/introduction.md Outdated Show resolved Hide resolved
```

The pipe symbol (`|`) connects the output of one command to the input of another.
`cut` reads the output of `cat`, and `sort` reads the output of `cut`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to take a step back and mention how many commands read from STDIN (and/or a file) and write to STDOUT? Introduce STDIN/STDOUT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'll do a "sneak preview" of I/O, with a promise of more to come in a later concept.

concepts/pipelines/introduction.md Outdated Show resolved Hide resolved
concepts/pipelines/introduction.md Outdated Show resolved Hide resolved
concepts/pipelines/introduction.md Show resolved Hide resolved
concepts/pipelines/introduction.md Outdated Show resolved Hide resolved
concepts/pipelines/introduction.md Outdated Show resolved Hide resolved
concepts/pipelines/introduction.md Outdated Show resolved Hide resolved
concepts/pipelines/introduction.md Outdated Show resolved Hide resolved
concepts/pipelines/introduction.md Outdated Show resolved Hide resolved
Copy link
Member

@kotp kotp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though draft, still looks good to me.

concepts/pipelines/.meta/config.json Outdated Show resolved Hide resolved
@glennj glennj marked this pull request as ready for review December 2, 2024 13:13
@glennj
Copy link
Contributor Author

glennj commented Dec 2, 2024

@IsaacG can I get your opinion on the I/O blurb please?

* A process can emit _error output_ on "stderr".

The `tr` command is a very pure example of this.
All it does is read text from its stdin, perform character transliterations, and print the resulting text to stdout.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We quote stdout in prior references, should we keep it consistent. It is a literal in the language as well. If we are generally talking about standard out and standard in, then expressing it in that way may be useful. Similar to standard input/output or I/O or something other than stdio as plain text, rather than somehow marked as the "thing" we are referencing in terms of the language, rather than an idea. Consistency is really what my comment is about, not only this line and close to this line, but throughout this document, at least.

Copy link
Member

@kotp kotp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggested changes, but still approved.


### Uses of Command Lists

Here are a couple of examples where command lists can simplify bash code.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Here are a couple of examples where command lists can simplify bash code.
Here are a couple of examples where command lists can simplify the code.

Because the context is Bash, we can likely reference it this way.


#### Reading blocks of lines from a file

Suppose you have a data file that represents points of a triangle as the length of the three sides but each on a separate line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Suppose you have a data file that represents points of a triangle as the length of the three sides but each on a separate line.
Suppose you have a data file that represents the sides of a triangle as the length of the three sides but each on a separate line.

It still seems a bit clunky or something with the change, but points never have a length, so we must be talking about something with a length, and that would be the sides.

assert(x == 5, "x must be 5");
```

We can use an OR operator in bash to simulate that function:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We can use an OR operator in bash to simulate that function:
We can use an OR operator in Bbash to simulate that function:

I believe Bash as a name of the scripting language should be capitalized, otherwise it appears as though we are talking about the executable, rather than the language.


## I/O

Before we start, a quick intro to input/output.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Before we start, a quick intro to input/output.
Before we start, a quick introduction to input/output, pretty commonly referenced as "I/O".

* By default, each command in a pipeline runs in a separate subshell.
(A subshell is a child process that is a copy of the currently running shell.)

* All the commands in a subshell execute in parallel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this always the case? Should we state that Bash is designed so that if it can, subshells are executed in parallel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, all the commands in a pipeline execute in parallel.

I can't find where in the manual this is stated, although I believe it to be true. I can just remove it.


#### Reading blocks of lines from a file

Suppose you have a data file that represents points of a triangle as the length of the three sides but each on a separate line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in the other file, I believe points by definition have no length, nor size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants